<template>
	<el-form :model="form" label-width="120px">
		<el-form-item label="Activity name">
			<el-input v-model="form.user" />
		</el-form-item>
			<el-form-item label="Activity name">
			<el-input v-model="form.pwd" />
		</el-form-item>
		<el-form-item>
			<el-button type="primary" @click="onSubmit">登录</el-button>
		</el-form-item>
	</el-form>
</template>

<script lang="ts" setup>
import { reactive } from 'vue'
import { useStore } from 'vuex'

const store = useStore()
// do not use same name with ref
const form = reactive({
	user: '',
	pwd: ''
})

const onSubmit = async () => {
	store.dispatch('login', form).then((data) => {
		console.log(data)
	}).catch((error) => {
		console.log(error)
	})
}
</script>
